import { createRouter, createWebHashHistory } from "vue-router";
import routes from "./routes";

import { isQuit } from "@/utils/tools";
const router = createRouter({
  history: createWebHashHistory(),
  routes,
});
router.beforeEach(to => {
  // 绑定页面离开事件，提醒用户 数据丢失 提示
  if (to.path === "/publish-contest" || to.path === "/publish-events") {
    window.addEventListener("beforeunload", isQuit);
  } else {
    window.removeEventListener("beforeunload", isQuit);
  }
});

export default router;
